class_name AbilityComponent
extends BaseComponent


@export_flags("移动","攻击","使用技能","交互","翻转","更新","造成伤害","受到伤害","恢复","选择目标","被选择","被击退") 
var cur_ability:int = pow(2,32)-1

signal on_cur_ability_changed(cur_ability,changed_ability)

func is_ability_valid(ability:GameEnum.EntityAbility)->bool:
	return cur_ability & ability > 0
func get_valid_ability()->GameEnum.EntityAbility:
	return cur_ability
func get_invalid_ability()->GameEnum.EntityAbility:
	return ~cur_ability
func set_ability(ability:GameEnum.EntityAbility,isValid:bool)->GameEnum.EntityAbility:
	var changed_ability:GameEnum.EntityAbility = cur_ability
	if isValid:
		cur_ability |= ability
	else:
		cur_ability &= ~ability
	changed_ability ^= cur_ability
	on_cur_ability_changed.emit(cur_ability,changed_ability)
	return changed_ability

func _init() -> void:
	component_name = "AbilityComponent"
